using System.Collections.Generic;
using UnityEngine;

public class EnemyAttack : MonoBehaviour
{
    public List<PlayerControl> DetectedList;
    public List<PlayerControl> AttackedList;
    public List<TrainBody> DetectedList2;
    public List<TrainBody> AttackedList2;
    [RegisterProperty("EnemyAttack")]
    public float damage;
    [RegisterProperty("EnemyAttack")]
    public float stun;
    [RegisterProperty("EnemyAttack")]
    public float knockback;

    private void Awake()
    {
        DetectedList = new List<PlayerControl>();
        AttackedList = new List<PlayerControl>();
        DetectedList2 = new List<TrainBody>();
        AttackedList2 = new List<TrainBody>();
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.transform.GetComponent<PlayerControl>() != null)
        {
            DetectedList.Add(collision.transform.GetComponent<PlayerControl>());
        }
        if (collision.transform.GetComponent<TrainBody>() != null)
        {
            DetectedList2.Add(collision.transform.GetComponent<TrainBody>());
        }
    }

    private void OnTriggerExit2D(Collider2D collision)
    {
        if (collision.transform.GetComponent<PlayerControl>() != null)
        {
            DetectedList.Remove(collision.transform.GetComponent<PlayerControl>());
        }
        if (collision.transform.GetComponent<TrainBody>() != null)
        {
            DetectedList2.Remove(collision.transform.GetComponent<TrainBody>());
        }
    }
}
